package com.agileai.bpm.controller.define;

import java.util.List;

import com.agileai.bpm.bizmoduler.define.WfProcessDefineSelect;
import com.agileai.domain.DataParam;
import com.agileai.domain.DataRow;
import com.agileai.hotweb.controller.core.BaseHandler;
import com.agileai.hotweb.domain.FormSelect;
import com.agileai.hotweb.domain.FormSelectFactory;
import com.agileai.hotweb.renders.LocalRenderer;
import com.agileai.hotweb.renders.ViewRenderer;

public class WfProcessDefineSelectHandler extends BaseHandler{
	public WfProcessDefineSelectHandler(){
		super();
		this.serviceId = "wfProcessDefineSelectService";
	}
	public ViewRenderer prepareDisplay(DataParam param){
		mergeParam(param);
		initParameters(param);
		this.setAttributes(param);
		WfProcessDefineSelect defineSelect = (WfProcessDefineSelect)this.lookupService(serviceId);
		param.put("WFP_STATE","released");
		List<DataRow> rsList = defineSelect.findRecords(param);
		this.setRsList(rsList);
		this.setAttributes(param);
		FormSelect stateSelect = FormSelectFactory.create("WF_STATE");
		this.setAttribute("stateSelect", stateSelect);
		return new LocalRenderer(getPage());
	}
	
	public ViewRenderer doQueryAction(DataParam param){
		return prepareDisplay(param);
	}
	
	protected void initParameters(DataParam param) {
        initParamItem(param, "wfpName", "");
        initParamItem(param, "wfpCode", "");
    }
}
